package cn.itcast.ks.controller.v1;

import cn.itcast.ks.api.UserControllerApi;
import cn.itcast.ks.common.ResponseResult;
import cn.itcast.ks.pojo.dtos.AddIntegralDto;
import cn.itcast.ks.pojo.dtos.TeacherDto;
import cn.itcast.ks.pojo.dtos.UserDto;
import cn.itcast.ks.pojo.entity.User;
import cn.itcast.ks.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author mwj
 * @date 2021/12/5
 * @TIME:15:48
 */
@RestController
@RequestMapping("/v1/user")
public class UserController implements UserControllerApi {
    @Autowired
    private IUserService userService;

    //根据班级ID查询所有的学生
    @GetMapping("/findByClassId")
    public ResponseResult findByClassId() {

        return userService.findByClassId();
    }

    //为用户添加积分
    @PostMapping("/addIntegral")
    public ResponseResult addIntegral(@RequestBody AddIntegralDto dto) {
        return userService.addIntegral(dto);
    }

    @Override
    public ResponseResult importUser(MultipartFile file) throws IOException {
        return null;
    }

    @Override
    public ResponseResult exportUser(HttpServletResponse response, Integer classId) throws IOException {
        return null;
    }

    //重置小组积分
    @Override
    @GetMapping("/resetGScoreByGroupId/{classId}")
    public ResponseResult resetGScoreByGroupId(@PathVariable Integer classId) {

        return userService.resetGScoreByGroupId(classId);
    }

    @Override
    public ResponseResult registerTeacher(TeacherDto dto) {
        return null;
    }


}
